//#include<stdio.h>
//#include<string.h>
//#include<unistd.h>
//#include<time.h>
//#include<stdlib.h>
//
//#define STYEL '='
//#define MAXDOWNSPEED 2000
//#define MINDOWNSPEED 1
//#define TOTAL 1000000

//int n=0;


#include"progress.h"
void Down()
{
   srand((unsigned int)time(NULL));
   char arr[101];
   memset(arr,0, sizeof(arr));
   const char* c="|/|\\";
   int download=0;
   int i=0;
   while(download<=TOTAL)
  {
    int speed =rand()%MAXDOWNSPEED + MINDOWNSPEED;
    download +=speed;  
    double t=100*(double)download/(double)TOTAL; 
    if(t>=100)
    {
      t=100.0;
    }
    int n=0;
    for(;n<=(int)t;n++)
    {
      arr[n]=STYEL;
    }
    
   printf("[%-100s][%.2f%%] [%c]\r", arr, t, c[i++%4]);
   fflush(stdout);
   usleep(3000);
   }
   printf("\n");
}



//#define SIZE 101
//#define STYLE '='
//
//void FlushProcess(double total, double curr) // 更新进度, 按照下载进度，进行更新进度条
//{
//    if(curr > total)
//        curr = total;
//    double rate = curr / total * 100; // 1024.0 , 512.0 -> 0.5 -> 50.0
//    int cnt = (int)rate; // 50.8 , 49.9 -> 50, 49
//    char processbuff[SIZE];
//    memset(processbuff, '\0', sizeof(processbuff));
//    int i = 0;
//    for(; i < cnt; i++)
//        processbuff[i] = STYLE;
//
//    static const char *lable = "|/-\\";
//    static int index = 0;
//    // 刷新
//    printf("[%-100s][%.1lf%%][%c]\r", processbuff, rate, lable[index++]);
//    index %= strlen(lable);
//    fflush(stdout);
//    if(curr >= total)
//    {
//        printf("\n");
//    }
//}
//
//int main()
//{
//
//}
